import Vue from 'vue'
import VueRouter from 'vue-router'
//home
import News from '../views/News.vue'
//user
import User from '../views/User.vue'
import Login from '../views/Login.vue'
import Register from '../views/Register.vue'
//user
import Setting from '../views/Setting.vue'
import MineImage from '../views/MineImage.vue'
import MineMessage from '../views/MineMessage.vue'
//news
import Contents from '../views/Contents.vue'
import NewsEdit from '../views/NewsEdit.vue'
import NewsDetail from '../views/NewsDetail.vue'

import axios from "../axios"
import store from "../store"

//404

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'news',
	component: News
    //redirect: { name : 'News' }
  },
  {
	  path: '/news',
	  name: 'news',
	  component: News
  },
  {
    path: '/login',
    name: 'login',
    component: Login,
	// meta{
	// 	title: '登录'
	// }
  },
  {
    path: '/register',
    name: 'register',
    component: Register,
	// meta{
	// 	title:'注册'
	// }
  },
  {
    path: '/user',
    name: 'user',
    component: User,
	meta: {
	  requireAuth: true
	}
	
  },
  {
    path: '/setting',
    name: 'setting',
    component: Setting,
	meta: {
	  requireAuth: true
	},
  	children: [
		{
		  path: '/',
		  name: 'minemsg',
		  component: MineMessage,
		  meta: {
		    requireAuth: true
		  }
		},
  		{
  		  path: '/mineimg',
  		  name: 'mineimg',
  		  component: MineImage,
		 meta: {
			  requireAuth: true
			}
  		},
  		{
  		  path: '/minemsg',
  		  name: 'minemsg',
  		  component: MineMessage,
		 meta: {
			  requireAuth: true
			}
  		},
  	]
  },
  
  {
    path: '/contents',
    name: 'contents',
    component: Contents,
	// meta{
	// 	title:'内容'
	// }
  },
  
  
  //授权验证
  {
    path: '/news/add',
    name: 'newsadd',
    component: NewsEdit,
    meta: {
      requireAuth: true
    }
  },
  
  {
    path: '/news/:newsId',
    name: 'newsdetail',
    component: NewsDetail
  },
//授权验证
  {
    path: '/news/:newsId/edit',
    name: 'newsedit',
    component: NewsEdit,
    meta: {
      requireAuth: true
    }
  },
	
	//--------------404-----------------
	    {
	      path: '/*',
	      name: 'error',
	      component: () => import('@/views/Error.vue')
	    }
  
  
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router

